﻿using System;
using System.Web.UI.WebControls;
using visinia.SmartEngine;

public partial class ClientScripts_Editors_LightEditor : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //editor
        WebPageController.AddScriptLink(Page, WebRoots.GetJsRoot + "Editors/jHtmlArea/jHtmlArea-0.7.0.min.js");
        WebPageController.AddCssLink(Page, WebRoots.GetJsRoot + "Editors/jHtmlArea/style/jHtmlArea.css");
        //visinia implemetation
        WebPageController.AddScriptLink(Page, WebRoots.GetJsRoot + "Editors/jHtmlArea/visinia-light-editor.js");
    }

    public string Text
    {
        get
        {
            // ie gives this problem it automatically replaces the relative urls 
            // with the absolute urls
            string content = Editor.Text;
            string root = WebRoots.GetWebRoot;
            string replace = "src=\"" + root + "image.axd?picture=";
            string replaceWith = "src=\"image.axd?picture=";
            string fixedContent = content.Replace(replace, replaceWith);
            return fixedContent;
        }
        set { Editor.Text = value; }
    }

    public Unit Width
    {
        get { return Editor.Width; }
        set { Editor.Width = value; }
    }

    public Unit Height
    {
        get { return Editor.Height; }
        set { Editor.Height = value; }
    }

    public string CssClass
    {
        get { return Editor.CssClass; }
        set { Editor.CssClass += " " + value; }
    }
}